// eslint-disable-next-line import/no-extraneous-dependencies
import type { Request, Response } from 'express';
import type { ListItemDataType } from '@/pages/Knowledge/data.d';

const titles = [
    '利用改进的归一化差异水体指数（MNDWI）提取水体信息的研究',
    '中国地表植被覆盖变化及其与气候因子关系──基于NOAA时间序列数据分析',
    '水体光谱测量与分析Ⅰ:水面以上测量法',
];
const avatars = [
    'https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png', // Alipay
    'https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png', // Angular
    'https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png', // Ant Design
    'https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png', // Ant Design Pro
    'https://gw.alipayobjects.com/zos/rmsportal/siCrBXXhmvTQGWPNLBow.png', // Bootstrap
    'https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png', // React
    'https://gw.alipayobjects.com/zos/rmsportal/ComBAopevLwENQdKWiIn.png', // Vue
    'https://gw.alipayobjects.com/zos/rmsportal/nxkuOJlFJuAUhzlMTCEe.png', // Webpack
];

const user = [
    '付小小',
    '曲丽丽',
    '林东东',
    '周星星',
    '吴加好',
    '朱偏右',
    '鱼酱',
    '乐哥',
    '谭小仪',
    '仲尼',
];

function fakeList(count: number): ListItemDataType[] {
    const list = [];
    for (let i = 0; i < count; i += 1) {
        list.push({
            id: `fake-list-${Math.random().toString(36).slice(2, 6)}${i}`,
            owner: '马小波',
            title: titles[i % 3],
            avatar: 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png',
            status: ['active', 'exception', 'normal'][i % 3] as
                | 'normal'
                | 'exception'
                | 'active'
                | 'success',
            percent: Math.ceil(Math.random() * 50) + 50,
            logo: avatars[i % 8],
            href: 'https://ant.design',
            updatedAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i).getTime(),
            createdAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i).getTime(),
            activeUser: Math.ceil(Math.random() * 100000) + 100000,
            newUser: Math.ceil(Math.random() * 1000) + 1000,
            star: Math.ceil(Math.random() * 100) + 100,
            like: Math.ceil(Math.random() * 100) + 100,
            message: Math.ceil(Math.random() * 10) + 10,
            content:
                '在对M cfeeters提出的归一化差异水体指数(NDWI)分析的基础上,对构成该指数的波长组合进行了修改,提出了改进的归一化差异水体指数MNDWI(M odified NDWI),并分别将该指数在含不同水体类型的遥感影像进行了实验,大部分获得了比NDWI好的效果,特别是提取城镇范围内的水体。NDWI指数影像因往往混有城镇建筑用地信息而使得提取的水体范围和面积有所扩大。',
            members: [
                {
                    avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ZiESqWwCXBRQoaPONSJe.png',
                    name: '曲丽丽',
                    id: 'member1',
                },
                {
                    avatar: 'https://gw.alipayobjects.com/zos/rmsportal/tBOxZPlITHqwlGjsJWaF.png',
                    name: '王昭君',
                    id: 'member2',
                },
                {
                    avatar: 'https://gw.alipayobjects.com/zos/rmsportal/sBxjgqiuHMGRkIjqlQCd.png',
                    name: '董娜娜',
                    id: 'member3',
                },
            ],
        });
    }

    return list;
}

function getFakeList(req: Request, res: Response) {
    const params: any = req.query;

    const count = params.count * 1 || 20;

    const result = fakeList(count);
    return res.json({
        data: {
            list: result,
        },
    });
}

export default {
    'GET  /mockApi/fake_list': getFakeList,
    'GET  /mockApi/structure': (req: Request, res: Response) => {
        return res.json({
            success: true,
            data: ['申报材料', '合同任务', '过程文档', '验收材料'],
        });
    },
};
